package seotools.positions;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 */
public class PriceLoader {
    public static void main(String[] args) throws IOException {
        String baseUrl = "http://www.isa-access.ru/";
        Document doc = Jsoup.connect(baseUrl).get();

        Map<String, String> categories = new HashMap<String, String>();
        Map<String, String> subCategories = new HashMap<String, String>();
        List<Item> items = new ArrayList<Item>();
        Elements categoryElems = doc.select("ul.cats li a");
        System.out.println(categoryElems);
        for (Element categoryElem : categoryElems) {
            String categoryName = categoryElem.text();
            String categoryUrl = categoryElem.attr("href");
            categories.put(categoryName, categoryUrl);
            System.out.println(categoryName + "->" + categoryUrl);
            doc = Jsoup.connect(baseUrl + categoryUrl + "?on_page=999999999").get();
            Elements subCategoryElems = doc.select("ul.cats li ul li a");
            for (Element subCategoryElem : subCategoryElems) {
                String subCategoryName = subCategoryElem.text();
                String subCategoryUrl = categoryElem.attr("href");
                subCategories.put(subCategoryName, subCategoryUrl);
                Item item = new Item();
            }
//            item.name =
        }
    }

    static class Category {
        Category parent;
        String name;
    }

    static class Item {
        String name;
        Category category;
        String comment;
        String price;
    }

}
